package io;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class WriteStringDemo {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入，退出请输入'exit'");
        while (true) {
            String q = scanner.nextLine();
            if ("exit".equalsIgnoreCase(q)){
                System.out.println("已保存,谢谢使用");
                break;
            }
            try (
                    FileOutputStream fos = new FileOutputStream("dome.txt",true)
            ){
                byte[] a = q.getBytes(StandardCharsets.UTF_8);
                fos.write(a);
                System.out.println("写入完毕,请继续");
            } catch (Exception e) {}
        }

    }
}
